package com.eshop.enums;

import java.util.stream.Stream;

public enum ProductEnum
{
    TYPE_1(Integer.valueOf(1), "精品推荐"), 
    TYPE_2(Integer.valueOf(2), "热门榜单"), 
    TYPE_3(Integer.valueOf(3), "首发新品"), 
    TYPE_4(Integer.valueOf(4), "猜你喜欢");
    
    private Integer value;
    private String desc;
    
    public static ProductEnum toType(final int value) {
        return Stream.of(values()).filter(p -> p.value == value).findAny().orElse(null);
    }
    
    public Integer getValue() {
        return this.value;
    }
    
    public String getDesc() {
        return this.desc;
    }
    
    private ProductEnum(final Integer value, final String desc) {
        this.value = value;
        this.desc = desc;
    }
}
